/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package mp.weixin.WXpublic.sendkefu;

import mp.weixin.WXpublic.BaseSendKefuMessage;
import org.codehaus.jackson.node.JsonNodeFactory;
import org.codehaus.jackson.node.ObjectNode;

/**
 *
 * @author aolin
 */
public class SKFMPNewsEntity extends BaseSendKefuMessage {

    public SKFMPNewsEntity(String openId, String mediaId) {
        super(openId);
        this.mediaId = mediaId;
    }
    private String mediaId;

    public String getMediaId() {
        return mediaId;
    }

    public void setMediaId(String mediaId) {
        this.mediaId = mediaId;
    }

    @Override
    public BaseSendKefuMessage.SendTypeEnum getMsgType() {
        return BaseSendKefuMessage.SendTypeEnum.MP_NEWS;
    }

    @Override
    public String toWeiXinKefuMessageJsonString() {
        ObjectNode jsono = new ObjectNode(JsonNodeFactory.instance);
        ObjectNode mpnews = new ObjectNode(JsonNodeFactory.instance);
        mpnews.put("media_id", this.getMediaId());
        jsono.put("touser", this.getToUser());
        jsono.put("msgtype", getMsgType().getType());
        jsono.put(getMsgType().getType(), mpnews);
        if (getKfAccount() != null && !getKfAccount().equals("")) {
            ObjectNode kf = new ObjectNode(JsonNodeFactory.instance);
            kf.put("kf_account", getKfAccount());
            jsono.put("customservice", kf);
        }
        return jsono.toString();
    }

}
